<?php
/*
 * OffLineAddWithDrawForm definition
 * @author li.junfu
 */
require_once BaseUtil::getModulePath("base")  .  '/forms/BaseForm.php';
require_once BaseUtil::getModulePath("trade")  .  '/constants/TradeConstant.php';
require_once BaseUtil::getModulePath("base")  . '/validate/Exist.php';
require_once BaseUtil::getModulePath("base")  . '/validate/LessThan.php';

class OffLineAddWithDrawForm extends BaseForm {

	public function __construct($data=array(),$in_bank=array()) {

		parent::__construct();
        //for i18n
        $translate = Zend_Registry::get('Zend_Translate');		
		$this->setAction(HttpUtil::getUrl("withdraw", "subadd"));

		//account
		$existValid = new Myvalidate_Exist ( );
		$existValid->setTableName ( 'users' );
		$existValid->setFieldName ( 'name' );
		$account = new Zend_Form_Element_Text('account');
		$account->addFilter("StringTrim");
		$account->setRequired(true);
		$account->addValidator($existValid);
		$account->setLabel($translate->_('userName'));


		//in_bank
		$in_bank = new Zend_Form_Element_Select('in_bank');
		$in_bank->setMultiOptions(TradeConstant::getBankTypeList());
		$in_bank->addFilter("StringTrim");
		$in_bank->setRequired(true);
		$in_bank->setLabel($translate->_('returnBank'));

		//in_name
		$in_name = new Zend_Form_Element_Text('in_name');
		$in_name->addFilter("StringTrim");
		$in_name->setRequired(true);
		$in_name->setLabel($translate->_('returnAccountName'));

		//in_bank_name
		$in_bank_name = new Zend_Form_Element_Text('in_bank_name');
		$in_bank_name->addFilter("StringTrim");
		$in_bank_name->setRequired(true);
		$in_bank_name->setLabel($translate->_('returnBankName'));

		//in_id
		$in_id = new Zend_Form_Element_Text('in_id');
		$in_id->addFilter("StringTrim");
		$in_id->setRequired(true);
        $in_id->setLabel($translate->_('returnAccount'));
        
		//tradesum
		$trade_sum = new Zend_Form_Element_Text('trade_sum');
		$trade_sum->addFilter("StringTrim");
		$trade_sum->setRequired(true);
		$trade_sum->addValidator("float");
		$lessThanValid = new Myvalidate_LessThan(0);
		$trade_sum->addValidator($lessThanValid);
		$trade_sum->setLabel($translate->_('withDrawSum'));

		//out_id
		//$out_id = new Zend_Form_Element_Text('out_id');
		//$out_id->addFilter("StringTrim");

		//submit
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setAttrib('id', 'submitbutton');

		$this->addElements(array($account,$in_bank,$in_bank_name,$in_name,$in_id,$trade_sum,$out_id,$submit));
		$this->setElementDecorators(array('ViewHelper',array(array('div'=>'HtmlTag'),array('tag'=>'div','class'=>'form_element'))));
	}
}
?>
